package com.andon.lcz.h264rtmp.pusher;

import android.app.Activity;
import android.hardware.Camera;
import android.view.SurfaceHolder;

import com.andon.lcz.h264rtmp.params.AudioParam;
import com.andon.lcz.h264rtmp.params.VideoParam;

public class LivePusher {

    private AudioPusher audioPusher;

    private VideoPusher videoPusher;

    private PusherNative pusherNative;

    public LivePusher(Activity activity, SurfaceHolder holder) {
        pusherNative = new PusherNative();
        audioPusher = new AudioPusher(new AudioParam(44100, 2), pusherNative);
        videoPusher = new VideoPusher(activity, pusherNative, new VideoParam(480, 320, Camera.CameraInfo.CAMERA_FACING_BACK), holder);
    }

    public void start(String url) {
        videoPusher.start();
        audioPusher.start();
        pusherNative.startPush(url);
    }

    public void stop() {
        audioPusher.stop();
        videoPusher.stop();
        pusherNative.stopPush();
    }

    public void switchCamera() {
        videoPusher.switchCamera();
    }
}
